/*     */ package com.feeyin.radar.task;
/*     */ 
/*     */ import com.feeyin.radar.commons.StringUtils;
/*     */ import com.feeyin.radar.sys.dao.ManageSetDAO;
/*     */ import com.feeyin.radar.sys.model.ManageSet;
/*     */ import java.io.PrintStream;
/*     */ import java.text.ParseException;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ import org.quartz.Scheduler;
/*     */ import org.quartz.SchedulerException;
/*     */ import org.springframework.scheduling.quartz.CronTriggerBean;
/*     */ 
/*     */ public class ChangeCronExpression
/*     */ {
/*     */   private Scheduler scheduler;
/*     */   private ManageSetDAO manageSetDAO;
/*     */ 
/*     */   public Scheduler getScheduler()
/*     */   {
/*  26 */     return this.scheduler;
/*     */   }
/*     */ 
/*     */   public void setScheduler(Scheduler scheduler) {
/*  30 */     this.scheduler = scheduler;
/*     */   }
/*     */ 
/*     */   public ManageSetDAO getManageSetDAO() {
/*  34 */     return this.manageSetDAO;
/*     */   }
/*     */ 
/*     */   public void setManageSetDAO(ManageSetDAO manageSetDAO) {
/*  38 */     this.manageSetDAO = manageSetDAO;
/*     */   }
/*     */ 
/*     */   public void changeBackupCronExpression()
/*     */   {
/*     */     try
/*     */     {
/*  46 */       String cronExpression = "";
/*  47 */       cronExpression = getBackupPlanExpression();
/*  48 */       if (StringUtils.isEmpty(cronExpression)) {
/*  49 */         cronExpression = "0 0 0 1 1 ? *";
/*     */       }
/*  51 */       System.out.println("cronExpression = " + cronExpression);
/*     */ 
/*  54 */       CronTriggerBean trigger = (CronTriggerBean)this.scheduler.getTrigger("backupCronTriggerBean", "DEFAULT");
/*  55 */       String originConExpression = trigger.getCronExpression();
/*     */ 
/*  58 */       if (!originConExpression.equalsIgnoreCase(cronExpression)) {
/*  59 */         trigger.setCronExpression(cronExpression);
/*  60 */         this.scheduler.rescheduleJob("backupCronTriggerBean", "DEFAULT", trigger);
/*     */       }
/*     */     }
/*     */     catch (SchedulerException e)
/*     */     {
/*  65 */       e.printStackTrace();
/*     */     } catch (ParseException e) {
/*  67 */       e.printStackTrace();
/*     */     }
/*     */   }
/*     */ 
/*     */   private String getBackupPlanExpression() {
/*  72 */     List list = new ArrayList();
/*  73 */     list = this.manageSetDAO.getManageSetByType("6");
/*  74 */     if ((list == null) || (list.size() <= 0)) return null;
/*     */ 
/*  76 */     String week = "";
/*  77 */     String hour = "";
/*  78 */     String minute = "";
/*  79 */     for (int i = 0; i < list.size(); i++) {
/*  80 */       ManageSet manageSet = new ManageSet();
/*  81 */       manageSet = (ManageSet)list.get(i);
/*  82 */       if ((StringUtils.isEmpty(manageSet.getStatus())) || 
/*  83 */         (!"1".equals(manageSet.getStatus()))) continue;
/*  84 */       if ("backupWeek".equals(manageSet.getCode()))
/*  85 */         week = manageSet.getMValue();
/*  86 */       else if ("backupHour".equals(manageSet.getCode()))
/*  87 */         hour = manageSet.getMValue();
/*  88 */       else if ("backupMinute".equals(manageSet.getCode())) {
/*  89 */         minute = manageSet.getMValue();
/*     */       }
/*     */ 
/*     */     }
/*     */ 
/*  95 */     String cronExpression = "";
/*  96 */     if ((!StringUtils.isEmpty(hour)) && (!StringUtils.isEmpty(minute))) {
/*  97 */       if (!StringUtils.isEmpty(week))
/*  98 */         cronExpression = "0 " + minute + " " + hour + " ? * " + week;
/*     */       else {
/* 100 */         cronExpression = "0 " + minute + " " + hour + " * * ?";
/*     */       }
/*     */     }
/* 103 */     return cronExpression;
/*     */   }
/*     */ }

/* Location:           C:\Users\e547415\MyProject\rone\WEB-INF\classes\
 * Qualified Name:     com.feeyin.radar.task.ChangeCronExpression
 * JD-Core Version:    0.6.0
 */